﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using Manager.DataAccess;


namespace Manager
{
    public partial class FrmAddRoom : DevExpress.XtraEditors.XtraForm
    {
        public FrmAddRoom()
        {
            InitializeComponent();
        }

        private void _btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                DataRoom droom = new DataRoom();
                droom.DienThoai = _txtDienThoai.Text;
                droom.GhiChu = _txtGhiChu.Text;
                droom.LoaiPhong = "1";         // -------------------------- Loai phong = 1 ----------------------------- //
                droom.MaPhong = _txtMaPhong.Text;
                droom.MaTang = int.Parse(_cbbMaTang.SelectedValue.ToString());
                droom.TenPhong = _txtTenPhong.Text.ToString();
                droom.TinhTrang = "1";
                droom.ViTri = int.Parse(_numViTri.Value.ToString());


                droom.Insert(droom);

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.Abort;
                MessageBox.Show(ex.ToString());
            }
        }

        private void _btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void FrmAddRoom_Load(object sender, EventArgs e)
        {
            DataDepartment ddep = new DataDepartment();
            DataTable dt = ddep.GetAll();
            _cbbMaTang.DataSource = dt;
            _cbbMaTang.DisplayMember = "TenTang";
            _cbbMaTang.ValueMember = "MaTang";

        }
    }
}
